<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const str = "学习前端";
      // 正则表达式使用
      // 定义规则
      const reg = /前端/;
      // 规则匹配
      console.log(reg.test(str)); // true
      console.log(reg.exec(str)); // 返回数组
    </script>
  </body>
</html>
